﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MayhemWpf.UserControls;
using ComputerMayhem.Events;
using Microsoft.WindowsAPICodePack.Net;

namespace ComputerMayhem.Wpf
{
    /// <summary>
    /// Interaction logic for LocationConfig.xaml
    /// </summary>
    public partial class NetworkNameConfig : WpfConfiguration
    {
        public NetworkNameConfig(NetworkNameOptions options)
        {
            InitializeComponent();
            
            var networks = NetworkListManager.GetNetworks(NetworkConnectivityLevels.All);
            foreach (var item in networks)
            {
                NetworkNameOptions option = new NetworkNameOptions() { Id = item.NetworkId, Name = item.Name };
                this.NetworksComboBox.Items.Add(option);
            }
            Options = options;
        }

        public override string Title
        {
            get
            {
                return "Network Name";
            }
        }

        public NetworkNameOptions Options
        {
            get;
            set;
        }

        public override void OnLoad()
        {
            this.NetworksComboBox.SelectedIndex = this.NetworksComboBox.Items.IndexOf(Options);
        }

        public override void OnSave()
        {
            var value = this.NetworksComboBox.SelectedValue;
            if (value != null && value is NetworkNameOptions)
            {
                Options = (NetworkNameOptions) value;
            }
        }

        private void NetworksComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.NetworksComboBox.SelectedValue != null)
            {
                CanSave = true;
            }
        }



    }
}
